public class ConsecutiveNumbersSum {
    public int consecutiveNumbersSum(int n) {
        int sum = 0;
        int ret = 0;
        for (int left = 1, right = 1; right <= n; right++) {
            sum += right;
            while (left <= right && sum >= n) {
                if (sum == n) {
                    ret++;
                }
                sum -= left++;
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        System.out.println(new ConsecutiveNumbersSum().consecutiveNumbersSum(933320757));
    }
}
